<!-- 评价内容 -->
<template>
	<view>
		<!-- 1.标题 -->
		<view id="bar">
			<uni-nav-bar title="评价内容" @clickLeft="back" left-text="返回" background-color='#88ACFF' color="#fff"
				statusBar="true"></uni-nav-bar>
		</view>
		<!-- bg -->
		<view class="top">
			<view class="bg"></view>
		</view>
		<!-- tab -->
		<view class="top-title-view">
			<view class="tab">
				<u-tabs :list="tabList" 
					keyName="connectName"
					lineColor="transparent"
					:activeStyle="{
						width: '100%',
						height: '100%',
						color: '#fff',
						fontSize: '14px',
						background: 'linear-gradient(270deg, #88ACFF 0%, #2165FF 100%)',
						transform: 'scale(1.05)',
					}" 
					:inactiveStyle="{
						color: '#002E96',
						fontSize: '14px',
						transform: 'scale(1)',
						width: '100%',
						height: '100%',
					}" 
					:itemStyle="itemStyle"
					@click="selectTab"
					>
				</u-tabs>
			</view>
		</view>
		<!-- 2.主体 -->
		<view class="main" v-if="true">
			<scroll-view class="scrollheight" scroll-y="true" :style="{height:setcollapseheight() - 108 + 'px'}"
			@scrolltolower="handleScrolltolowerone()">
				<view v-for="item in appraiseList" :key="item.id" class="item">
					<view class="top">
						<view class="first-line">
							<template>
								<image src="@/static/socialized-service/nz/person.png" v-if="item.avatar == null" mode=""></image>
								<image :src="item.avatar" v-else mode=""></image>
							</template>
							<view class="name">
								{{item.servicerUserName}}
							</view>
						</view>
						<view class="second-line">
							<view class="left">
								{{item.description}}
							</view>
							<view class="right">
								{{item.createTime}}
							</view>
						</view>
						<view class="third-line">
							<view class="third-item" v-for="(it,itIndex) in item.pictureList" :key="itIndex">
								<image :src="it" mode="" @click="lookBigImg(it)"></image>
							</view>
						</view>
					</view>
				</view>
				<view class="bottom-ios-lineline">

				</view>
				<view class="bottom-ios-line">

				</view>
			</scroll-view>
		</view>
		<view v-else>
			<view class="blank">
				<image src="@/static/blank.png" mode=""></image>
				<view class="nodata">
					暂无数据
				</view>
			</view>
		</view>
		<u-overlay :show="overlayFlag" @click="overlayFlag = false">
				<view class="warp">
					<image :src="overlayUrl" mode="heightFix" class="img"></image>
				</view>
			</u-overlay>
		<view class="bottom-ios-line">

		</view>
	</view>
</template>

<script>
	import API from '@/api/socialized-servce/farm-service/normalUser/serviceSelect/service-organization/appraise-content/index.js'
	export default {
		data() {
			return {
				page: 1,
				total: 0,
				organizationNo: '',
				tabList: [],
				tabIndex: 0,
				serviceProviderNo: '',
				appraiseList: [],
				itemStyle: {
					padding: '0',
					color: 'red',
					marginRight: '15px',
					width: '103px',
					height: '29px',
					borderRadius: '15px',
					overflow: 'hidden',
				},
				overlayFlag: false,
				overlayUrl: ''
			}
		},
		onLoad(e) {
			this.organizationNo = e.organizationNo
		},
		mounted() {
			this.getProjectSumList()
			this.setcollapseheight()
		},
		methods: {
			selectTab(item) {
				this.page = 1
				this.serviceProviderNo = item.code
				this.getOrganizationAppraise()
			},
			// 查询tabs
			async getProjectSumList() {
				let params = {
					organizationNo: this.organizationNo
				}
				let res = await API.queryProjectSum(params)
				if(res.code === 200) {
					this.tabList = res.data
					this.serviceProviderNo = res.data[0].code
					this.getOrganizationAppraise()
					this.tabList.forEach(el=>{
						el['connectName'] = `${el.name}(${el.value})`
					})
				}
			},
			// 分页查询
			async getOrganizationAppraise(scroll = false) {
				let params = {
					page: this.page,
					size: 10,
					condition: {
						serviceProjectNo: this.serviceProviderNo,
						organizationNo: this.organizationNo
					}
				}
				let res = await API.queryOrganizationAppraise(params)
				if(res.code === 200) {
					this.total = res.data.totalElements
					if(scroll) {
						let newList = res.data.content
						this.appraiseList = [...this.appraiseList,...newList]
					} else {
						this.appraiseList = res.data.content
					}
					
				}
			},
			handleScrolltolowerone() {
				if(this.page * 10 < this.total) {
					this.page++
					this.getOrganizationAppraise(true)
				}
			},
			//  设置可选择设施高度
			setcollapseheight() {
				let topheightone = uni.upx2px(136)
				// let newheight = this.customBar + topheightone
				let winHeight = 0
				uni.getSystemInfo({
					success: function(res) {
						winHeight = res.windowHeight
					}
				});
				let oldHeight = uni.upx2px(136)

				winHeight = parseInt(winHeight) - topheightone
				// #ifndef H5
				winHeight = winHeight

				// #endif
				return winHeight
			},
			back() {
				uni.redirectTo({
					url: `/subPage1/socialized-service/farm-service/normalUser/serviceSelect/service-organization/service-organization`
				})
			},
			lookBigImg(e) {
				this.overlayUrl = e
				this.overlayFlag = true
			}
		}
	}
</script>

<style lang="scss" scoped>
	// bg
	.top {
		position: relative;
		z-index: 999;
		top: -4rpx;
		width: 100%;
		height: 64rpx;

		.bg {
			position: absolute;
			top: 0rpx;
			height: 64rpx;
			width: 100%;
			background: linear-gradient(141deg, #88ACFF 0%, #2165FF 100%);
		}

	}

	// tab
	.top-title-view {
		position: relative;
		top: -64rpx;
		width: 692rpx;
		height: 128rpx;
		// margin-top: 20rpx;
		padding: 0 32rpx;
		z-index: 9999;
	}
	.tab {
		position: relative;
		width: 100%;
		height: 100%;
		background-color: #fff;
		border-radius: 30rpx 30rpx 30rpx 30rpx;
		// overflow: hidden;
	}
	/deep/.u-tabs {
		transform: translateY(50%);
	}
	
	/deep/ .u-tabs__wrapper__nav__item {
		position: relative;
		border: 1px solid rgba(0,0,0,0.16);
		padding: 0 20rpx!important;
		box-shadow: 0px 0px -2rpx 1rpx rgba(0,0,0,0.16);
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	
	/deep/.u-tabs__wrapper__nav__item__text {
		position: absolute;
		display: flex;
		flex-wrap: nowrap;
		justify-content: center;
		align-items: center;
		
	}

	// 主体
	.main {
		width: 100%;
		height: 100%;
		margin-top: -40rpx;
		background-color: red;
		background: #F5F6FA;

		.item {
			display: flex;
			box-sizing: border-box;
			height: 308rpx;
			padding: 28rpx;
			margin: 0 40rpx;
			margin-bottom: 20rpx;
			background: #FFFFFF;
			box-shadow: 0px 3px 6px 1px rgba(0,0,0,0.05);
			border-radius: 5px 5px 5px 5px;
			.top {
				width: 100%;
				.first-line {
					width: 100%;
					display: flex;
					align-items: center;
					image {
						width: 74rpx;
						height: 68rpx;
						border-radius: 50%;
					}
					.name {
						margin-left: 14rpx;
						font-size: 32rpx;
						font-family: Source Han Sans CN-Bold, Source Han Sans CN;
						font-weight: bold;
						color: #91743E;
					}
				}
				.second-line {
					margin-top: 16rpx;
					display: flex;
					justify-content: space-between;
					font-size: 24rpx;
					font-family: Source Han Sans CN-Regular, Source Han Sans CN;
					font-weight: 400;
					color: #5C5C5C;
					.right {
						font-size: 24rpx;
						font-family: Arial-Regular, Arial;
						font-weight: 400;
						color: #222222;
					}
				}
				.third-line {
					display: flex;
					width: 100%;
					margin-top: 18rpx;
					.third-item {
						margin-right: 18rpx;
						width: 192rpx;
						height: 128rpx;
						image {
							width: 100%;
							height: 100%;
						}
					}
				}
			}
		}
	}

	.blank {
		position: absolute;
		width: 100%;
		top: 50%;
		transform: translateY(-50%);
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;

		image {
			width: 200rpx;
			height: 200rpx;
		}

		.nodata {
			margin-top: 20rpx;
		}
	}

	#bar {
		::v-deep .uni-navbar__header {
			box-shadow: none !important;
			background: linear-gradient(141deg, #88ACFF 0%, #2165FF 100%) !important;
			color: #fff !important;
			border-bottom: 1px solid #e9eaee;

			.uni-nav-bar-text {
				color: #fff !important;
			}

			.uni-icons::before {
				color: #fff !important;
			}
		}
	}
	
	.warp {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}
</style>